package kxfang.com.common.utils;

import androidx.lifecycle.Lifecycle;
import androidx.lifecycle.LifecycleObserver;
import androidx.lifecycle.LifecycleRegistry;
import androidx.lifecycle.OnLifecycleEvent;

import com.google.gson.Gson;

import java.util.ArrayList;
import java.util.List;

import io.reactivex.disposables.Disposable;
import kxfang.com.http.EasyHttp;
import kxfang.com.http.callback.SimpleCallBack;

/**
 * Created by WL
 * on 2020/8/22
 * Class Content
 */
public class HttpUtils implements LifecycleObserver {

    private static List<Disposable> list = new ArrayList<>();
    private static List<LifecycleRegistry> lifeList = new ArrayList<>();

    public static <T, B> void doHttp(LifecycleRegistry life,String url, T json, SimpleCallBack<B> callBack) {
        Disposable disposable = EasyHttp.post(url)
                                        .cacheKey(url)
                                        .upJson(new Gson().toJson(json))
                                        .execute(callBack);
    }

    @OnLifecycleEvent(Lifecycle.Event.ON_STOP)
    public void stop(){

    }
}
